const dotenv = require('dotenv')

process.env.NODE_ENV = process.env.NODE_ENV || 'development'
const isDev = process.env.NODE_ENV === 'development'
const ENV_PATH = isDev ? '.env.dev' : '.env.prod'

const env = dotenv.config({ path: ENV_PATH })
if (env.error) {
  throw new Error("⚠️  Couldn't find .env file  ⚠️")
}

module.exports = {
  port: parseInt(process.env.PORT),
  isDev,
  database: {
    dbName: process.env.DB_NAME,
    username: process.env.DB_USERNAME,
    password: process.env.DB_PASSWORD,
    host: process.env.DB_HOST,
    port: process.env.DB_PORT,
  },
  security: {
    secret: 'dasdadassdad', // 密匙
    // 过期时间 1小时
    expiresIn: 60 * 60,
  },
}
